<?php
autoLoader();

$mid 	= ( ( true == isset( $_GET['mid'] ) && true == valStr( $_GET['mid'] ) ) ? $_GET['mid'] : NULL );
$smid 	= ( ( true == isset( $_GET['smid'] ) && true == valStr( $_GET['smid'] ) ) ? $_GET['smid'] : NULL );

if( false == isset( $_GET['case_paper_id'] ) || false == valStr( $_GET['case_paper_id'] ) ) {
	echo "<h1>Faild to load case paper data.</h1>";
	exit;
}

$objTemplate = new Templates();

$strSql = 'SELECT * FROM templates WHERE case_paper_id = ' . $_GET['case_paper_id'] . ';';

$arrobjTemplates = $objTemplate->fetchSql( $strSql );
$arrobjTemplates = rekeyObjects( 'TemplateType', $arrobjTemplates );

$objCasePaper = new CasePapers();
$objCasePaper = $objCasePaper->fetchCasePapersById( $_GET['case_paper_id'] );

?>
<div id="main_continar" style="margin-top: 15px;">
	<div id="working_ara">
		<div id="print_area">
			<div class="main_border">
				<div id="print_header">
					<div id="main_header" style="text-align: center;">
						<div>SARDAR VALLABHABHAI PATEL CANTONMENT GENETAL HOSPITAL</div>
						<div>Golibar Maidan, Shankar Sheth Road, Pune - 411 001.</div>
						<div><u>OPD patient Details:</u></div>
					</div>
					<hr/>
					<div class="left_div">
						<label>Patien Name:- <?php echo "Somnath Shinde"; ?></label>
					</div>
					<div class="right_div">
						<label>Date:- <?php echo date( 'd/m/Y H:m:s' ); ?></label>
					</div>
					<div style="clear: both;"></div>
					
					<div class="left_div">
						<label>Case Paper Id: <?php echo 1201; ?></label>
					</div>
					<div class="right_div">
						<label>Doctor Name:- <?php echo "SOm shine"; ?></label>
					</div>
					<div style="clear: both;"></div>
					
					<hr/>
					
					<div id="case_paper_details">
						<div id="row1">
							<div id="cheif_compeltaints" class="left_div">
								<label>Cheif Completaints:-</label>
								<div>
									<?php 
										$objCheifTemplate = getArrayElementByKey( TemplateType::TEMPLATE_CHIEF_COMPLAINTS, $arrobjTemplates );
										if( true == valObj( $objCheifTemplate, 'BaseTemplates' ) ) {
											echo html_entity_decode( $objCheifTemplate->getData() );
										}
									?> 
								</div>
							</div>
							
							<div id="prescription" class="right_div">
								<label>Prescription:-</label>
								<div>
									<?php 
										$objPrescriptionTemplate = getArrayElementByKey( TemplateType::TEMPLATE_PRESCRIPTION, $arrobjTemplates );
										if( true == valObj( $objPrescriptionTemplate, 'BaseTemplates' ) ) {
											echo html_entity_decode( $objPrescriptionTemplate->getData() );
										}
									?> 
								</div>
							</div>
							<div style="clear: both;"></div>
						</div>
						
						<hr/>
						<div id="row2">
							<div id="diagnosis" class="left_div">
								<label>Diagnosis:-</label>
								<div>
									<?php 
										$objDignosisTemplate = getArrayElementByKey( TemplateType::TEMPLATE_DIAGNOSIS, $arrobjTemplates );
										if( true == valObj( $objDignosisTemplate, 'BaseTemplates' ) ) {
											echo html_entity_decode( $objDignosisTemplate->getData() );
										}
									?> 
								</div>
							</div>
							<div id="investigation" class="right_div">
								<label>Investigation:-</label>
								<div>
									<?php 
										$objInvestigationTemplate = getArrayElementByKey( TemplateType::TEMPLATE_INVESTIGATION, $arrobjTemplates );
										if( true == valObj( $objInvestigationTemplate, 'BaseTemplates' ) ) {
											echo html_entity_decode( $objInvestigationTemplate->getData() );
										}
									?>
								</div>
							</div>
							<div style="clear: both;"></div>
						</div>
						
						<hr/>
						<div id="row3">
							<div id="follow_up_date" class="left_div">
								<label>FollowUp Date:-</label>
								<div>
									<?php 
										if( true == valObj( $objCasePaper, 'BaseCasePapers' ) ) {
											echo date( 'd-m-Y', strtotime( $objCasePaper->getFollowupDate() ) );
										}
									?>
								</div>
							</div>
							<div id="remark" class="right_div">
								<label>Remark:-</label>
								<div>
									<?php 
										$objRemarkTemplate = getArrayElementByKey( TemplateType::TEMPLATE_REMARK, $arrobjTemplates );
										if( true == valObj( $objRemarkTemplate, 'BaseTemplates' ) ) {
											echo html_entity_decode( $objRemarkTemplate->getData() );
										}
									?>  
								</div>
							</div>
							<div style="clear: both;"></div>
						</div>
				</div>
			</div>
		</div>
	</div>
	
	<div style="text-align: center; margin-top: 25px;">
		<input type="button" name="print" value="--Print--" onclick="PrintDoc();" />
		<input type="button" name="print_preview" value="--Print Preview--" onclick="PrintPreview();" />
		<a href="modules.php?file=opd_case_paper&mid=<?php echo $mid;?>&smid=<?php echo $smid;?>" title="Go to OPD module" style="color: black;"><input type="button" name="cancel" value="--Cancel--" /></a>
	</div>
	<div style="text-align: center; margin-top: 10px;">
		<a href="modules.php?file=opd_case_paper&action=update&patient_id=<?php if( true == isset( $_GET['patient_id'] ) && true == valStr( $_GET['patient_id'] ) ) { echo $_GET['patient_id']; }?>&case_paper_id=<?php echo $_GET['case_paper_id'];?>&mid=<?php echo $mid;?>&smid=<?php echo $smid;?>" title="Update old case paper information"><input type="button" name="edit" value="--Edit Case Paper--" /></a>
		<a href="modules.php?file=view_case_papers&type=view&mid=<?php echo $mid;?>&smid=<?php echo $smid;?>" title="View All case papers"><input type="button" name="view" value="--View All Case Papers--" /></a>
	</div>
</div>

<style>
div.left_div {
	float: left;
	margin-left: 20px;
	width: 50%;
}
div.right_div {
	float: right;
	width: 40%;
}

div.main_border {
	margin:auto;
	width:78%;
	border: 2px;
	border-style: solid;
}
	
@media screen /*--This is for Screen--*/
{
	.btn {
		background-color: #AFAFAF;
		display: block;
	}

	.tble {
		background-color: #E5E5E5;
		border: 1px solid #CD853F;
	}
}
</style>

<script type="text/javascript">

/*--This JavaScript method for Print command--*/

function PrintDoc() {
	var toPrint = document.getElementById('print_area');
	var popupWin = window.open('', '_blank', 'width=650,height=350,location=no,left=200px');

	popupWin.document.open();
	popupWin.document.write('<html><title>::Preview::</title><link rel="stylesheet" type="text/css" href="css/printing.css" /></head><body onload="window.print()">')
	popupWin.document.write( toPrint.innerHTML );
	popupWin.document.write('</html>');
	popupWin.document.close();
}

/*--This JavaScript method for Print Preview command--*/
function PrintPreview() {
	var toPrint = document.getElementById('print_area');
	var popupWin = window.open('', '_blank', 'width=650,height=350,location=no,left=200px');

	popupWin.document.open();
	popupWin.document.write('<html><title>::Print Preview::</title><link rel="stylesheet" type="text/css" href="css/printing.css" media="screen"/></head><body">')
	popupWin.document.write( toPrint.innerHTML );
	popupWin.document.write('</html>');
	popupWin.document.close();
}
</script>